﻿//////////////////////////////////////////////////////////////////////////////
//
// Copyright © 1998-2024 Glodon Company Limited.
//
// Licensed under the MIT License
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the “Software”),
// to deal in the Software without restriction, including without limitation
// the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
// sell copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
//////////////////////////////////////////////////////////////////////////////
#include "GmGraphicsStyleFilter.h"

#include "IBehaviorConfig.h"
#include "IPublishConfig.h"
#include "IFamilyManager.h"
#include "ThemeManager.h"
#include "UniIdentity.h"
#include "ICategory.h"
#include "IFamilyManager.h"
#include "IElementBasicInformation.h"
#include "GcmpBuiltInCategoryUniIdentities.h"
#include "GbmpBuiltInCategoryUniIdentitiesNew.h"
#include "IGraphicsStyleData.h"
#include "ICategoryLibrary.h"
#include "ILinkElementProxy.h"
#include "IGraphicsStyleManager.h"
#include "IGraphicsStyle.h"
#include "IGraphicsMaterialManager.h"
#include "EnableCompileWarning_The_LAST_IncludeInCpp.h"

using namespace gcmp;

// 暂时处理ThemeManager废弃警告，后续ThemeManager私有化后把这里恢复

CREATE_DEBUG_MODE(TestCuttableElementByPlanView, L"测试裁剪元素接口", gcmp::DebugModeGroup::DMGT_OTHERS, L"GDMPLab", L"2023-12-20", L"测试IsCuttableElementByPlanViewCutPlane接口，打开的话，链接代理对象不被平面剖切。");


/// \brief 通过类别UniIdentity获得内建类别
/// \param categoryUid 类别UniIdentity
/// \return 类别
#define GET_BUILT_IN_CATEGORY(pCategoryLibrary, categoryUid) \
        pCategoryLibrary->GetCategory(categoryUid)

namespace
{
    OwnerPtr<IGraphicsStyleData> GetGraphicsStyleDataOfThemeDefaultGraphics(EnThemeDefaultGraphics themeDefaultGraphics)
    {
        ThemeManager* pThemeMgr = ThemeManager::GetInstance();
        OwnerPtr<IGraphicsStyleData> opGraphicsStyleData = pThemeMgr->GetGStyleData(themeDefaultGraphics);
        DBG_WARN_AND_RETURN_NULLPTR_UNLESS(opGraphicsStyleData, L"pThemeMgr->GetGStyleData(...) 返回空指针",L"GDMPLab",L"2024-03-30");
        return opGraphicsStyleData;
    }

    bool CreateGraphicsStyleAndGraphicsMaterialForCategoryExt(IDocument* pDocument, const UniIdentity& categoryUid, const OwnerPtr<IGraphicsStyleData> opGraphicsStyleData)
    {
        DBG_WARN_AND_RETURN_FALSE_UNLESS(pDocument, L"pDocument为空",L"GDMPLab",L"2024-03-30");
        DBG_WARN_AND_RETURN_FALSE_UNLESS(opGraphicsStyleData, L"pGraphicsStyleData为空",L"GDMPLab",L"2024-03-30");
        DBG_WARN_AND_RETURN_FALSE_UNLESS(categoryUid.IsValid(), L"Category的UniIdentity不合法",L"GDMPLab",L"2024-03-30");

        IGraphicsStyleManager* pGStyleMgr = pDocument->GetGraphicsStyleManager();
        DBG_WARN_AND_RETURN_FALSE_UNLESS(pGStyleMgr, L"pGStyleMgr is nullptr",L"GDMPLab",L"2024-03-30");
        ElementId styleId = pGStyleMgr->GetGraphicsStyleIdByCategoryUid(categoryUid);
        if (styleId != ElementId::InvalidID)
            return true;
        pGStyleMgr->CreateGraphicsStyleForCategory(categoryUid, *opGraphicsStyleData);

        ICategoryLibrary* pCatLib = ICategoryLibrary::Get(pDocument);
        DBG_WARN_AND_RETURN_FALSE_UNLESS(pCatLib, L"pGStyleMgr is nullptr",L"GDMPLab",L"2024-03-30");
        const ICategory* pCatetory = pCatLib->GetCategory(categoryUid);
        DBG_WARN_AND_RETURN_FALSE_UNLESS(pCatetory, L"pGStyleMgr is nullptr",L"GDMPLab",L"2024-03-30");
        if (!pCatetory->CanHaveGraphicsMaterial())
        {
            return true;
        }

        IGraphicsMaterialManager* pMatMgr = pDocument->GetGraphicsMaterialManager();
        DBG_WARN_AND_RETURN_FALSE_UNLESS(pMatMgr, L"pGStyleMgr is nullptr",L"GDMPLab",L"2024-03-30");
        ElementId matId = pMatMgr->GetGraphicsMaterialIdByCategoryUid(categoryUid);
        if (matId != ElementId::InvalidID)
            return true;
        pMatMgr->CreateGraphicsMaterialForCategory(categoryUid);

        return true;
    }
}

GmGraphicsStyleFilter::GmGraphicsStyleFilter()
{
    // 项目对象样式
    if (m_projectCategories.size() == 0)
    {
        m_projectCategories.insert(BuiltInCategoryUniIdentities::BICU_STRUCTURE_WALL);
        m_projectCategories.insert(BuiltInCategoryUniIdentities::BICU_STRUCTURE_COLUMN);
        m_projectCategories.insert(BuiltInCategoryUniIdentities::BICU_STRUCTURE_BEAM);
        m_projectCategories.insert(BuiltInCategoryUniIdentities::BICU_STRUCTURE_FLOOR);
        m_projectCategories.insert(BuiltInCategoryUniIdentities::BICU_STAIR);
        m_projectCategories.insert(BuiltInCategoryUniIdentities::BICU_WINDOW);
        m_projectCategories.insert(BuiltInCategoryUniIdentities::BICU_DOOR);
        m_projectCategories.insert(BuiltInCategoryUniIdentities::BICU_ROOF);
        // 照明设备
        // 家具
        // 卫浴装置
        m_projectCategories.insert(BuiltInCategoryUniIdentities::BICU_RAILING);
        m_projectCategories.insert(BuiltInCategoryUniIdentities::BICU_POINT_FAMILY);
        m_projectCategories.insert(BuiltInCategoryUniIdentities::BICU_LINE_FAMILY);
        m_projectCategories.insert(BuiltInCategoryUniIdentities::BICU_ELEVATION);
        m_projectCategories.insert(BuiltInCategoryUniIdentities::BICU_REFERENCE_PLANE);
        m_projectCategories.insert(BuiltInCategoryUniIdentities::BICU_GRID);
        m_projectCategories.insert(BuiltInCategoryUniIdentities::BICU_MODEL_LINE);
        m_projectCategories.insert(BuiltInCategoryUniIdentities::BICU_VIEW_SYMBOL);
        m_projectCategories.insert(BuiltInCategoryUniIdentities::BICU_DIMENSION_TEXT);
        // 二维线

        m_projectCategories.insert(BuiltInCategoryUniIdentities::BICU_MECHANICAL_EQUIPMENT);
        m_projectCategories.insert(BuiltInCategoryUniIdentities::BICU_AIR_PIPE_FITTINGS);
        m_projectCategories.insert(BuiltInCategoryUniIdentities::BICU_AIR_PIPE_ACCESSORY);
        m_projectCategories.insert(BuiltInCategoryUniIdentities::BICU_PIPE_FITTINGS);
        m_projectCategories.insert(BuiltInCategoryUniIdentities::BICU_PIPE_LINE_ACCESSORY);

        // 链接模型
        m_projectCategories.insert(BuiltInCategoryUniIdentities::BICU_LINK_DOCUMENT_ELEMENT);

        m_projectCategories.insert(BuiltInCategoryUniIdentities::BICU_TEST_MODEL_BODY);
    }

    if (m_geolabCategories.size() == 0)
    {
        m_geolabCategories.insert(BuiltInCategoryUniIdentities::BICU_POINT_FAMILY);
        m_geolabCategories.insert(BuiltInCategoryUniIdentities::BICU_LINE_FAMILY);
        m_geolabCategories.insert(BuiltInCategoryUniIdentities::BICU_ELEVATION);
        m_geolabCategories.insert(BuiltInCategoryUniIdentities::BICU_REFERENCE_PLANE);
        m_geolabCategories.insert(BuiltInCategoryUniIdentities::BICU_SKETCH_LINE);
        m_geolabCategories.insert(BuiltInCategoryUniIdentities::BICU_MODEL_LINE);
        m_geolabCategories.insert(BuiltInCategoryUniIdentities::BICU_VIEW_SYMBOL);
        m_geolabCategories.insert(BuiltInCategoryUniIdentities::BICU_FAM_CONSTRAINT);
        m_geolabCategories.insert(BuiltInCategoryUniIdentities::BICU_DIMENSION_TEXT);
        // 二维线
        m_geolabCategories.insert(BuiltInCategoryUniIdentities::BICU_SKETCH_LOCATION_LINE);
        //参照线
        m_geolabCategories.insert(BuiltInCategoryUniIdentities::BICU_REFERENCE_LINE);
        m_geolabCategories.insert(BuiltInCategoryUniIdentities::BICU_MEPCONNECTOR);
        // 链接模型
        m_geolabCategories.insert(BuiltInCategoryUniIdentities::BICU_LINK_DOCUMENT_ELEMENT);
    }

    if (m_familyEditorCategories.size() == 0)
    {
        m_familyEditorCategories.insert(BuiltInCategoryUniIdentities::BICU_ELEVATION);
        m_familyEditorCategories.insert(BuiltInCategoryUniIdentities::BICU_FORM);
        m_familyEditorCategories.insert(BuiltInCategoryUniIdentities::BICU_POINT_FAMILY);
        m_familyEditorCategories.insert(BuiltInCategoryUniIdentities::BICU_REFERENCE_PLANE);
        m_familyEditorCategories.insert(BuiltInCategoryUniIdentities::BICU_SKETCH_LINE);
        m_familyEditorCategories.insert(BuiltInCategoryUniIdentities::BICU_LINE_FAMILY);
        m_familyEditorCategories.insert(BuiltInCategoryUniIdentities::BICU_FAM_CONSTRAINT);
        m_familyEditorCategories.insert(BuiltInCategoryUniIdentities::BICU_SKETCH_LOCATION_LINE);
        m_familyEditorCategories.insert(BuiltInCategoryUniIdentities::BICU_REFERENCELINE_DATUMPLANE);
        m_familyEditorCategories.insert(BuiltInCategoryUniIdentities::BICU_MEPCONNECTOR);
    }

    if (m_structuralDetailingCategoriesExcluded.size() == 0)
    {
        m_structuralDetailingCategoriesExcluded.insert(BuiltInCategoryUniIdentities::BICU_SKETCH_ROOF_BOUNDARY_CURVE);
        m_structuralDetailingCategoriesExcluded.insert(BuiltInCategoryUniIdentities::BICU_CURSOR_TIP);
        m_structuralDetailingCategoriesExcluded.insert(BuiltInCategoryUniIdentities::BICU_ROOF);
        m_structuralDetailingCategoriesExcluded.insert(BuiltInCategoryUniIdentities::BICU_SKETCH);
        m_structuralDetailingCategoriesExcluded.insert(BuiltInCategoryUniIdentities::BICU_REFERENCED_CURVE);
        m_structuralDetailingCategoriesExcluded.insert(BuiltInCategoryUniIdentities::BICU_STAIR);
        m_structuralDetailingCategoriesExcluded.insert(BuiltInCategoryUniIdentities::BICU_WORK_PLANE);
        m_structuralDetailingCategoriesExcluded.insert(BuiltInCategoryUniIdentities::BICU_AUXILIARY_ELEMENT);
        m_structuralDetailingCategoriesExcluded.insert(BuiltInCategoryUniIdentities::BICU_REFERENCE_PLANE);
        m_structuralDetailingCategoriesExcluded.insert(BuiltInCategoryUniIdentities::BICU_MAGICAD_FAMILY);
        m_structuralDetailingCategoriesExcluded.insert(BuiltInCategoryUniIdentities::BICU_SKETCH_AXIS_LINE);
        m_structuralDetailingCategoriesExcluded.insert(BuiltInCategoryUniIdentities::BICU_SKETCH_LINE);
        m_structuralDetailingCategoriesExcluded.insert(BuiltInCategoryUniIdentities::BICU_TEMP_DIMENSION_TEXT);
        m_structuralDetailingCategoriesExcluded.insert(BuiltInCategoryUniIdentities::BICU_SKETCH_PLANE);
        m_structuralDetailingCategoriesExcluded.insert(BuiltInCategoryUniIdentities::BICU_POINT_SET);
        m_structuralDetailingCategoriesExcluded.insert(BuiltInCategoryUniIdentities::BICU_FAM_CONSTRAINT);
        m_structuralDetailingCategoriesExcluded.insert(BuiltInCategoryUniIdentities::BICU_TEMP_DIMENSION_REFERENCE_LINE);
        m_structuralDetailingCategoriesExcluded.insert(BuiltInCategoryUniIdentities::BICU_DISTANCE_CONSTRAINT);
        m_structuralDetailingCategoriesExcluded.insert(BuiltInCategoryUniIdentities::BICU_TEMP_DIMENSION_HEAD);
        m_structuralDetailingCategoriesExcluded.insert(BuiltInCategoryUniIdentities::BICU_SNAP_HIGHLIGHT);
        m_structuralDetailingCategoriesExcluded.insert(BuiltInCategoryUniIdentities::BICU_SKETCH_LOCATION_LINE);
        m_structuralDetailingCategoriesExcluded.insert(BuiltInCategoryUniIdentities::BICU_IMPORTED_CAD_OBJECT);
        m_structuralDetailingCategoriesExcluded.insert(BuiltInCategoryUniIdentities::BICU_SNAP_POINT);
        m_structuralDetailingCategoriesExcluded.insert(BuiltInCategoryUniIdentities::BICU_TEMP_DIMENSION_LINE);
        m_structuralDetailingCategoriesExcluded.insert(BuiltInCategoryUniIdentities::BICU_RAILING);
        m_structuralDetailingCategoriesExcluded.insert(BuiltInCategoryUniIdentities::BICU_WORK_PLANE_GRID);
        m_structuralDetailingCategoriesExcluded.insert(BuiltInCategoryUniIdentities::BICU_TEMP_STYLE);
        m_structuralDetailingCategoriesExcluded.insert(BuiltInCategoryUniIdentities::BICU_CONSTRAINT_SIGN);
        m_structuralDetailingCategoriesExcluded.insert(BuiltInCategoryUniIdentities::BICU_DOC_REFERENCE.GetGuid());
        m_structuralDetailingCategoriesExcluded.insert(BuiltInCategoryUniIdentities::BICU_REFERENCE_LINE);
        m_structuralDetailingCategoriesExcluded.insert(BuiltInCategoryUniIdentities::BICU_REFERENCELINE_DATUMPLANE);
        m_structuralDetailingCategoriesExcluded.insert(BuiltInCategoryUniIdentities::BICU_MECHANICAL_EQUIPMENT);
        m_structuralDetailingCategoriesExcluded.insert(BuiltInCategoryUniIdentities::BICU_AIR_PIPE_FITTINGS);
        m_structuralDetailingCategoriesExcluded.insert(BuiltInCategoryUniIdentities::BICU_AIR_PIPE_ACCESSORY);
        m_structuralDetailingCategoriesExcluded.insert(BuiltInCategoryUniIdentities::BICU_PIPE_FITTINGS);
        m_structuralDetailingCategoriesExcluded.insert(BuiltInCategoryUniIdentities::BICU_PROFILE_EDIT_PLANE);
        m_structuralDetailingCategoriesExcluded.insert(BuiltInCategoryUniIdentities::BICU_PIPE_LINE_ACCESSORY);
    }
}

GmGraphicsStyleFilter::~GmGraphicsStyleFilter()
{
}

bool GmGraphicsStyleFilter::InitializeBuiltInCategoriesForProject(ICategoryLibrary* pCategoryLibrary) const
{
    DBG_WARN_AND_RETURN_FALSE_UNLESS(pCategoryLibrary, L"pCategoryLibrary为空",L"GDMPLab",L"2024-03-30");
    auto AddCategoryExt = [](ICategoryLibrary* pCategoryLibrary, const ICategory* pCategory)->bool {
        DBG_WARN_AND_RETURN_FALSE_UNLESS(pCategoryLibrary && pCategory, L"传入参数为空",L"GDMPLab",L"2024-03-30");
        pCategoryLibrary->AddCategory(pCategory->Clone());
        return true;
    };

    bool res = AddCategoryExt(pCategoryLibrary, GET_BUILT_IN_CATEGORY(pCategoryLibrary, BuiltInCategoryUniIdentities::BICU_WALL))
        && AddCategoryExt(pCategoryLibrary, GET_BUILT_IN_CATEGORY(pCategoryLibrary, BuiltInCategoryUniIdentities::BICU_WINDOW))
        && AddCategoryExt(pCategoryLibrary, GET_BUILT_IN_CATEGORY(pCategoryLibrary, BuiltInCategoryUniIdentities::BICU_DOOR))
        && AddCategoryExt(pCategoryLibrary, GET_BUILT_IN_CATEGORY(pCategoryLibrary, BuiltInCategoryUniIdentities::BICU_STAIR))
        && AddCategoryExt(pCategoryLibrary, GET_BUILT_IN_CATEGORY(pCategoryLibrary, BuiltInCategoryUniIdentities::BICU_COLUMN))
        && AddCategoryExt(pCategoryLibrary, GET_BUILT_IN_CATEGORY(pCategoryLibrary, BuiltInCategoryUniIdentities::BICU_BEAM))
        && AddCategoryExt(pCategoryLibrary, GET_BUILT_IN_CATEGORY(pCategoryLibrary, BuiltInCategoryUniIdentities::BICU_ROOF))
        && AddCategoryExt(pCategoryLibrary, GET_BUILT_IN_CATEGORY(pCategoryLibrary, BuiltInCategoryUniIdentities::BICU_FLOOR))
        && AddCategoryExt(pCategoryLibrary, GET_BUILT_IN_CATEGORY(pCategoryLibrary, BuiltInCategoryUniIdentities::BICU_PROFILE))
        && AddCategoryExt(pCategoryLibrary, GET_BUILT_IN_CATEGORY(pCategoryLibrary, BuiltInCategoryUniIdentities::BICU_RAILING))
        && AddCategoryExt(pCategoryLibrary, GET_BUILT_IN_CATEGORY(pCategoryLibrary, BuiltInCategoryUniIdentities::BICU_HANDRAIL))
        && AddCategoryExt(pCategoryLibrary, GET_BUILT_IN_CATEGORY(pCategoryLibrary, BuiltInCategoryUniIdentities::BICU_BALUSTER))
        && AddCategoryExt(pCategoryLibrary, GET_BUILT_IN_CATEGORY(pCategoryLibrary, BuiltInCategoryUniIdentities::BICU_LEVEL_TYPE))
        && AddCategoryExt(pCategoryLibrary, GET_BUILT_IN_CATEGORY(pCategoryLibrary, BuiltInCategoryUniIdentities::BICU_ELEVATION))
        && AddCategoryExt(pCategoryLibrary, GET_BUILT_IN_CATEGORY(pCategoryLibrary, BuiltInCategoryUniIdentities::BICU_GRID))
        && AddCategoryExt(pCategoryLibrary, GET_BUILT_IN_CATEGORY(pCategoryLibrary, BuiltInCategoryUniIdentities::BICU_GRID_TAG))
        && AddCategoryExt(pCategoryLibrary, GET_BUILT_IN_CATEGORY(pCategoryLibrary, BuiltInCategoryUniIdentities::BICU_MAGICAD_FAMILY))
        && AddCategoryExt(pCategoryLibrary, GET_BUILT_IN_CATEGORY(pCategoryLibrary, BuiltInCategoryUniIdentities::BICU_MECHANICAL_EQUIPMENT))
        && AddCategoryExt(pCategoryLibrary, GET_BUILT_IN_CATEGORY(pCategoryLibrary, BuiltInCategoryUniIdentities::BICU_AIR_PIPE_FITTINGS))
        && AddCategoryExt(pCategoryLibrary, GET_BUILT_IN_CATEGORY(pCategoryLibrary, BuiltInCategoryUniIdentities::BICU_AIR_PIPE_ACCESSORY))
        && AddCategoryExt(pCategoryLibrary, GET_BUILT_IN_CATEGORY(pCategoryLibrary, BuiltInCategoryUniIdentities::BICU_PIPE_FITTINGS))
        && AddCategoryExt(pCategoryLibrary, GET_BUILT_IN_CATEGORY(pCategoryLibrary, BuiltInCategoryUniIdentities::BICU_PIPE_LINE_ACCESSORY))

        //////////////////////////////////////////////////////////////////////////
        /// 新GBMP
        // 结构构件
        && AddCategoryExt(pCategoryLibrary, GET_BUILT_IN_CATEGORY(pCategoryLibrary, BuiltInCategoryUniIdentities::BICU_STRUCTURE_WALL))
        && AddCategoryExt(pCategoryLibrary, GET_BUILT_IN_CATEGORY(pCategoryLibrary, BuiltInCategoryUniIdentities::BICU_STRUCTURE_COLUMN))
        && AddCategoryExt(pCategoryLibrary, GET_BUILT_IN_CATEGORY(pCategoryLibrary, BuiltInCategoryUniIdentities::BICU_STRUCTURE_BEAM))
        && AddCategoryExt(pCategoryLibrary, GET_BUILT_IN_CATEGORY(pCategoryLibrary, BuiltInCategoryUniIdentities::BICU_STRUCTURE_FLOOR))
        && AddCategoryExt(pCategoryLibrary, GET_BUILT_IN_CATEGORY(pCategoryLibrary, BuiltInCategoryUniIdentities::BICU_STRUCTURE_PLATE_HOLE))
        && AddCategoryExt(pCategoryLibrary, GET_BUILT_IN_CATEGORY(pCategoryLibrary, BuiltInCategoryUniIdentities::BICU_STRUCTURE_SLOPELINE))
        && AddCategoryExt(pCategoryLibrary, GET_BUILT_IN_CATEGORY(pCategoryLibrary, BuiltInCategoryUniIdentities::BICU_STRUCTURE_FOUNDATION))
        && AddCategoryExt(pCategoryLibrary, GET_BUILT_IN_CATEGORY(pCategoryLibrary, BuiltInCategoryUniIdentities::BICU_STRUCTURE_STRIP_FOUNDATION))
        && AddCategoryExt(pCategoryLibrary, GET_BUILT_IN_CATEGORY(pCategoryLibrary, BuiltInCategoryUniIdentities::BICU_STRUCTURE_WALL_HOLE))
        && AddCategoryExt(pCategoryLibrary, GET_BUILT_IN_CATEGORY(pCategoryLibrary, BuiltInCategoryUniIdentities::BICU_NEW_LEVEL_TYPE))
        && AddCategoryExt(pCategoryLibrary, GET_BUILT_IN_CATEGORY(pCategoryLibrary, BuiltInCategoryUniIdentities::BICU_NEW_ELEVATION))
        && AddCategoryExt(pCategoryLibrary, GET_BUILT_IN_CATEGORY(pCategoryLibrary, BuiltInCategoryUniIdentities::BICU_NEW_GRID))
        && AddCategoryExt(pCategoryLibrary, GET_BUILT_IN_CATEGORY(pCategoryLibrary, BuiltInCategoryUniIdentities::BICU_NEW_GRID_TAG))
        && AddCategoryExt(pCategoryLibrary, GET_BUILT_IN_CATEGORY(pCategoryLibrary, BuiltInCategoryUniIdentities::BICU_ELEVATION_VIEW_SYMBOL))
        && AddCategoryExt(pCategoryLibrary, GET_BUILT_IN_CATEGORY(pCategoryLibrary, BuiltInCategoryUniIdentities::BICU_VIEW_SYMBOL_AUXILIARY_BORDER))
        && AddCategoryExt(pCategoryLibrary, GET_BUILT_IN_CATEGORY(pCategoryLibrary, BuiltInCategoryUniIdentities::BICU_SECTION_VIEW_SYMBOL))
        && AddCategoryExt(pCategoryLibrary, GET_BUILT_IN_CATEGORY(pCategoryLibrary, BuiltInCategoryUniIdentities::BICU_SECTION_VIEW_SYMBOL_LINE))
        && AddCategoryExt(pCategoryLibrary, GET_BUILT_IN_CATEGORY(pCategoryLibrary, BuiltInCategoryUniIdentities::BICU_STAIR_VIEW_SYMBOL))
        && AddCategoryExt(pCategoryLibrary, GET_BUILT_IN_CATEGORY(pCategoryLibrary, BuiltInCategoryUniIdentities::BICU_STAIR_VIEW_SYMBOL_LINE))
        //机电连接件
        && AddCategoryExt(pCategoryLibrary, GET_BUILT_IN_CATEGORY(pCategoryLibrary, BuiltInCategoryUniIdentities::BICU_MEPCONNECTOR))

        // 相机
        && AddCategoryExt(pCategoryLibrary, GET_BUILT_IN_CATEGORY(pCategoryLibrary, BuiltInCategoryUniIdentities::BICU_CAMERA))

        // REVIT通用对象
        && AddCategoryExt(pCategoryLibrary, GET_BUILT_IN_CATEGORY(pCategoryLibrary, BuiltInCategoryUniIdentities::BICU_REVIT_ELEMENT))
        && AddCategoryExt(pCategoryLibrary, GET_BUILT_IN_CATEGORY(pCategoryLibrary, BuiltInCategoryUniIdentities::BICU_HOOPING_BAR))
        && AddCategoryExt(pCategoryLibrary, GET_BUILT_IN_CATEGORY(pCategoryLibrary, BuiltInCategoryUniIdentities::BICU_LONGITUDINAL_BAR))

        //暂时只提供类别，不提供系统内置族
        && AddCategoryExt(pCategoryLibrary, GET_BUILT_IN_CATEGORY(pCategoryLibrary, BuiltInCategoryUniIdentities::BICU_ARCHITECTURE_WALL))
        && AddCategoryExt(pCategoryLibrary, GET_BUILT_IN_CATEGORY(pCategoryLibrary, BuiltInCategoryUniIdentities::BICU_ARCHITECTURE_COLUMN))
        && AddCategoryExt(pCategoryLibrary, GET_BUILT_IN_CATEGORY(pCategoryLibrary, BuiltInCategoryUniIdentities::BICU_CONSTRUCTIONAL_FLOOR))
        && AddCategoryExt(pCategoryLibrary, GET_BUILT_IN_CATEGORY(pCategoryLibrary, BuiltInCategoryUniIdentities::BICU_NEW_ROOF))
        && AddCategoryExt(pCategoryLibrary, GET_BUILT_IN_CATEGORY(pCategoryLibrary, BuiltInCategoryUniIdentities::BICU_CEILING))
        && AddCategoryExt(pCategoryLibrary, GET_BUILT_IN_CATEGORY(pCategoryLibrary, BuiltInCategoryUniIdentities::BICU_CURTAIN_WALL))
        && AddCategoryExt(pCategoryLibrary, GET_BUILT_IN_CATEGORY(pCategoryLibrary, BuiltInCategoryUniIdentities::BICU_NEW_STAIR))
        && AddCategoryExt(pCategoryLibrary, GET_BUILT_IN_CATEGORY(pCategoryLibrary, BuiltInCategoryUniIdentities::BICU_NEW_HANDRAIL))
        && AddCategoryExt(pCategoryLibrary, GET_BUILT_IN_CATEGORY(pCategoryLibrary, BuiltInCategoryUniIdentities::BICU_RAMP))
        && AddCategoryExt(pCategoryLibrary, GET_BUILT_IN_CATEGORY(pCategoryLibrary, BuiltInCategoryUniIdentities::BICU_NEW_DOOR))
        && AddCategoryExt(pCategoryLibrary, GET_BUILT_IN_CATEGORY(pCategoryLibrary, BuiltInCategoryUniIdentities::BICU_NEW_WINDOW))
        && AddCategoryExt(pCategoryLibrary, GET_BUILT_IN_CATEGORY(pCategoryLibrary, BuiltInCategoryUniIdentities::BICU_SITE))
        && AddCategoryExt(pCategoryLibrary, GET_BUILT_IN_CATEGORY(pCategoryLibrary, BuiltInCategoryUniIdentities::BICU_COMMON_COMPONENT));

    DBG_WARN_AND_RETURN_FALSE_UNLESS(res, L"pCategoryLibrary->AddCategory失败",L"GDMPLab",L"2024-03-30");
    return true;
}

bool GmGraphicsStyleFilter::InitializeGraphicsStyleAndGraphicsMaterialOfBuiltInCategoriesForProject(gcmp::IDocument* pDoc)const
{
    OwnerPtr<IGraphicsStyleData> opGraphicsStyleData = IGraphicsStyleData::Create();
    DBG_WARN_AND_RETURN_FALSE_UNLESS(opGraphicsStyleData, L"IGraphicsStyleData::Create() 返回空指针",L"GDMPLab",L"2024-03-30");

    bool res = CreateGraphicsStyleAndGraphicsMaterialForCategoryExt(pDoc, BuiltInCategoryUniIdentities::BICU_WALL, GetGraphicsStyleDataOfThemeDefaultGraphics(TDG_Category_Wall))
        && CreateGraphicsStyleAndGraphicsMaterialForCategoryExt(pDoc, BuiltInCategoryUniIdentities::BICU_WINDOW, GetGraphicsStyleDataOfThemeDefaultGraphics(TDG_Category_Window))
        && CreateGraphicsStyleAndGraphicsMaterialForCategoryExt(pDoc, BuiltInCategoryUniIdentities::BICU_DOOR, GetGraphicsStyleDataOfThemeDefaultGraphics(TDG_Category_Door))
        && CreateGraphicsStyleAndGraphicsMaterialForCategoryExt(pDoc, BuiltInCategoryUniIdentities::BICU_STAIR, GetGraphicsStyleDataOfThemeDefaultGraphics(TDG_Category_Stair))
        && CreateGraphicsStyleAndGraphicsMaterialForCategoryExt(pDoc, BuiltInCategoryUniIdentities::BICU_COLUMN, GetGraphicsStyleDataOfThemeDefaultGraphics(TDG_Category_Column))
        && CreateGraphicsStyleAndGraphicsMaterialForCategoryExt(pDoc, BuiltInCategoryUniIdentities::BICU_BEAM, GetGraphicsStyleDataOfThemeDefaultGraphics(TDG_Category_Beam))
        && CreateGraphicsStyleAndGraphicsMaterialForCategoryExt(pDoc, BuiltInCategoryUniIdentities::BICU_ROOF, GetGraphicsStyleDataOfThemeDefaultGraphics(TDG_Category_Roof))
        && CreateGraphicsStyleAndGraphicsMaterialForCategoryExt(pDoc, BuiltInCategoryUniIdentities::BICU_FLOOR, GetGraphicsStyleDataOfThemeDefaultGraphics(TDG_Category_Floor))
        && CreateGraphicsStyleAndGraphicsMaterialForCategoryExt(pDoc, BuiltInCategoryUniIdentities::BICU_RAILING, GetGraphicsStyleDataOfThemeDefaultGraphics(TDG_Category_Railing))
        && CreateGraphicsStyleAndGraphicsMaterialForCategoryExt(pDoc, BuiltInCategoryUniIdentities::BICU_PROFILE, opGraphicsStyleData->Reset().Clone())
        && CreateGraphicsStyleAndGraphicsMaterialForCategoryExt(pDoc, BuiltInCategoryUniIdentities::BICU_ELEVATION, opGraphicsStyleData->Reset().SetColor(Color(0, 85, 255)).SetSectionFaceColor(Color(0, 85, 255)).SetProjectionLineTypeName(L"Grid Line").SetProjectionLineColor(Color(0, 85, 255)).SetSectionLineColor(Color(0, 85, 255)).SetSectionLineTypeName(L"Grid Line").Clone())
        && CreateGraphicsStyleAndGraphicsMaterialForCategoryExt(pDoc, BuiltInCategoryUniIdentities::BICU_GRID, opGraphicsStyleData->Reset().SetColor(Color(100, 100, 100)).SetSectionFaceColor(Color(100, 100, 100)).SetProjectionLineTypeName(L"Grid Line").SetProjectionLineColor(Color(100, 100, 100)).SetSectionLineColor(Color(100, 100, 100)).SetSectionLineTypeName(L"Grid Line").Clone())
        && CreateGraphicsStyleAndGraphicsMaterialForCategoryExt(pDoc, BuiltInCategoryUniIdentities::BICU_GRID_TAG, opGraphicsStyleData->Reset().SetColor(Color(100, 100, 100)).SetSectionFaceColor(Color(100, 100, 100)).SetProjectionLineColor(Color(100, 100, 100)).SetSectionLineColor(Color(100, 100, 100)).Clone())
        && CreateGraphicsStyleAndGraphicsMaterialForCategoryExt(pDoc, BuiltInCategoryUniIdentities::BICU_MAGICAD_FAMILY, opGraphicsStyleData->Reset().Clone())
        && CreateGraphicsStyleAndGraphicsMaterialForCategoryExt(pDoc, BuiltInCategoryUniIdentities::BICU_MECHANICAL_EQUIPMENT, GetGraphicsStyleDataOfThemeDefaultGraphics(TDG_Category_MEPConnector))
        && CreateGraphicsStyleAndGraphicsMaterialForCategoryExt(pDoc, BuiltInCategoryUniIdentities::BICU_AIR_PIPE_FITTINGS, GetGraphicsStyleDataOfThemeDefaultGraphics(TDG_Category_MEPConnector))
        && CreateGraphicsStyleAndGraphicsMaterialForCategoryExt(pDoc, BuiltInCategoryUniIdentities::BICU_AIR_PIPE_ACCESSORY, GetGraphicsStyleDataOfThemeDefaultGraphics(TDG_Category_MEPConnector))
        && CreateGraphicsStyleAndGraphicsMaterialForCategoryExt(pDoc, BuiltInCategoryUniIdentities::BICU_PIPE_FITTINGS, GetGraphicsStyleDataOfThemeDefaultGraphics(TDG_Category_MEPConnector))
        && CreateGraphicsStyleAndGraphicsMaterialForCategoryExt(pDoc, BuiltInCategoryUniIdentities::BICU_PIPE_LINE_ACCESSORY, GetGraphicsStyleDataOfThemeDefaultGraphics(TDG_Category_MEPConnector))
        && CreateGraphicsStyleAndGraphicsMaterialForCategoryExt(pDoc, BuiltInCategoryUniIdentities::BICU_TEST_MODEL_BODY, TransferOwnership(opGraphicsStyleData->Reset().SetColor(Color(180, 180, 180)).Clone()))
        //机电连接件
        && CreateGraphicsStyleAndGraphicsMaterialForCategoryExt(pDoc, BuiltInCategoryUniIdentities::BICU_MEPCONNECTOR, opGraphicsStyleData->Reset().SetColor(Color(255, 167, 79, 255)).SetSectionFaceColor(Color(255, 167, 79, 255)).SetProjectionLineColor(Color(255, 167, 79, 255)).SetSectionLineColor(Color(255, 167, 79, 255)).Clone())

        //////////////////////////////////////////////////////////////////////////
        /// 新GBMP
        // 结构构件
        && CreateGraphicsStyleAndGraphicsMaterialForCategoryExt(pDoc, BuiltInCategoryUniIdentities::BICU_STRUCTURE_WALL, GetGraphicsStyleDataOfThemeDefaultGraphics(TDG_Category_Wall))
        && CreateGraphicsStyleAndGraphicsMaterialForCategoryExt(pDoc, BuiltInCategoryUniIdentities::BICU_STRUCTURE_COLUMN, GetGraphicsStyleDataOfThemeDefaultGraphics(TDG_Category_Column))
        && CreateGraphicsStyleAndGraphicsMaterialForCategoryExt(pDoc, BuiltInCategoryUniIdentities::BICU_STRUCTURE_BEAM, GetGraphicsStyleDataOfThemeDefaultGraphics(TDG_Category_Beam))
        && CreateGraphicsStyleAndGraphicsMaterialForCategoryExt(pDoc, BuiltInCategoryUniIdentities::BICU_STRUCTURE_FLOOR, GetGraphicsStyleDataOfThemeDefaultGraphics(TDG_Category_Floor))
        && CreateGraphicsStyleAndGraphicsMaterialForCategoryExt(pDoc, BuiltInCategoryUniIdentities::BICU_STRUCTURE_PLATE_HOLE, opGraphicsStyleData->Reset().SetColor(Color(100, 100, 100)).SetSectionFaceColor(Color(100, 100, 100)).SetTransparency(0.0).Clone())
        && CreateGraphicsStyleAndGraphicsMaterialForCategoryExt(pDoc, BuiltInCategoryUniIdentities::BICU_STRUCTURE_SLOPELINE, GetGraphicsStyleDataOfThemeDefaultGraphics(TDG_Category_SlopeLine))
        && CreateGraphicsStyleAndGraphicsMaterialForCategoryExt(pDoc, BuiltInCategoryUniIdentities::BICU_STRUCTURE_FOUNDATION, GetGraphicsStyleDataOfThemeDefaultGraphics(TDG_Category_Foundation))
        && CreateGraphicsStyleAndGraphicsMaterialForCategoryExt(pDoc, BuiltInCategoryUniIdentities::BICU_STRUCTURE_STRIP_FOUNDATION, GetGraphicsStyleDataOfThemeDefaultGraphics(TDG_Category_Foundation))
        && CreateGraphicsStyleAndGraphicsMaterialForCategoryExt(pDoc, BuiltInCategoryUniIdentities::BICU_STRUCTURE_WALL_HOLE, opGraphicsStyleData->Reset().SetColor(Color(100, 100, 100)).SetSectionFaceColor(Color(100, 100, 100)).SetTransparency(0.0).Clone())

        && CreateGraphicsStyleAndGraphicsMaterialForCategoryExt(pDoc, BuiltInCategoryUniIdentities::BICU_NEW_ELEVATION, opGraphicsStyleData->Reset().SetColor(Color(0, 85, 255)).SetSectionFaceColor(Color(0, 85, 255)).SetProjectionLineTypeName(L"Grid Line").SetProjectionLineColor(Color(0, 85, 255)).SetSectionLineColor(Color(0, 85, 255)).SetSectionLineTypeName(L"Grid Line").Clone())
        && CreateGraphicsStyleAndGraphicsMaterialForCategoryExt(pDoc, BuiltInCategoryUniIdentities::BICU_NEW_GRID, opGraphicsStyleData->Reset().SetColor(Color(100, 100, 100)).SetSectionFaceColor(Color(100, 100, 100)).SetProjectionLineTypeName(L"Grid Line").SetProjectionLineColor(Color(100, 100, 100)).SetSectionLineColor(Color(100, 100, 100)).SetSectionLineTypeName(L"Grid Line").Clone())
        && CreateGraphicsStyleAndGraphicsMaterialForCategoryExt(pDoc, BuiltInCategoryUniIdentities::BICU_NEW_GRID_TAG, opGraphicsStyleData->Reset().SetColor(Color(100, 100, 100)).SetSectionFaceColor(Color(100, 100, 100)).SetProjectionLineColor(Color(100, 100, 100)).SetSectionLineColor(Color(100, 100, 100)).Clone())
        && CreateGraphicsStyleAndGraphicsMaterialForCategoryExt(pDoc, BuiltInCategoryUniIdentities::BICU_ELEVATION_VIEW_SYMBOL, opGraphicsStyleData->Reset().SetColor(Color(0, 0, 0)).SetSectionFaceColor(Color(0, 0, 0)).SetProjectionLineColor(Color(0, 0, 0)).SetProjectionLineWidth(2).SetSectionLineColor(Color(0, 0, 0)).Clone())
        && CreateGraphicsStyleAndGraphicsMaterialForCategoryExt(pDoc, BuiltInCategoryUniIdentities::BICU_VIEW_SYMBOL_AUXILIARY_BORDER, opGraphicsStyleData->Reset().SetProjectionLineTypeName(L"DASHED").SetProjectionLineColor(Color(0, 85, 255)).Clone())
        && CreateGraphicsStyleAndGraphicsMaterialForCategoryExt(pDoc, BuiltInCategoryUniIdentities::BICU_SECTION_VIEW_SYMBOL, opGraphicsStyleData->Reset().SetColor(Color(0, 0, 0)).SetSectionFaceColor(Color(0, 0, 0)).SetProjectionLineColor(Color(0, 0, 0)).SetSectionLineColor(Color(0, 0, 0)).SetProjectionLineWidth(3).Clone())
        && CreateGraphicsStyleAndGraphicsMaterialForCategoryExt(pDoc, BuiltInCategoryUniIdentities::BICU_NEW_ROOF, GetGraphicsStyleDataOfThemeDefaultGraphics(TDG_Category_New_Roof))
        && CreateGraphicsStyleAndGraphicsMaterialForCategoryExt(pDoc, BuiltInCategoryUniIdentities::BICU_SECTION_VIEW_SYMBOL_LINE, opGraphicsStyleData->Reset().SetColor(Color(0, 0, 0)).SetSectionFaceColor(Color(0, 0, 0)).SetProjectionLineTypeName(L"DASHED").SetProjectionLineColor(Color(0, 0, 0)).SetSectionLineColor(Color(0, 0, 0)).SetSectionLineTypeName(L"DASHED").Clone())
        && CreateGraphicsStyleAndGraphicsMaterialForCategoryExt(pDoc, BuiltInCategoryUniIdentities::BICU_STAIR_VIEW_SYMBOL, opGraphicsStyleData->Reset().SetColor(Color(0, 0, 0)).SetSectionFaceColor(Color(0, 0, 0)).SetProjectionLineColor(Color(0, 0, 0)).SetSectionLineColor(Color(0, 0, 0)).SetProjectionLineWidth(3).Clone())
        && CreateGraphicsStyleAndGraphicsMaterialForCategoryExt(pDoc, BuiltInCategoryUniIdentities::BICU_STAIR_VIEW_SYMBOL_LINE, opGraphicsStyleData->Reset().SetColor(Color(0, 0, 0)).SetSectionFaceColor(Color(0, 0, 0)).SetProjectionLineTypeName(L"DASHED").SetProjectionLineColor(Color(0, 0, 0)).SetSectionLineColor(Color(0, 0, 0)).SetSectionLineTypeName(L"DASHED").Clone())

        // 相机
        && CreateGraphicsStyleAndGraphicsMaterialForCategoryExt(pDoc, BuiltInCategoryUniIdentities::BICU_CAMERA, opGraphicsStyleData->Reset().SetColor(Color(120, 175, 35)).SetSectionFaceColor(Color(120, 175, 35)).SetTransparency(1.0).Clone())

        // REVIT通用对象
        && CreateGraphicsStyleAndGraphicsMaterialForCategoryExt(pDoc, BuiltInCategoryUniIdentities::BICU_REVIT_ELEMENT, GetGraphicsStyleDataOfThemeDefaultGraphics(TDG_Category_RevitElement))
        && CreateGraphicsStyleAndGraphicsMaterialForCategoryExt(pDoc, BuiltInCategoryUniIdentities::BICU_HOOPING_BAR, GetGraphicsStyleDataOfThemeDefaultGraphics(TDG_Category_HoopingBar))
        && CreateGraphicsStyleAndGraphicsMaterialForCategoryExt(pDoc, BuiltInCategoryUniIdentities::BICU_LONGITUDINAL_BAR, GetGraphicsStyleDataOfThemeDefaultGraphics(TDG_Category_LongitudinalBar))

        //暂时只提供类别，不提供系统内置族
        && CreateGraphicsStyleAndGraphicsMaterialForCategoryExt(pDoc, BuiltInCategoryUniIdentities::BICU_ARCHITECTURE_WALL, GetGraphicsStyleDataOfThemeDefaultGraphics(TDG_Category_Architecture_Wall))
        && CreateGraphicsStyleAndGraphicsMaterialForCategoryExt(pDoc, BuiltInCategoryUniIdentities::BICU_ARCHITECTURE_COLUMN, GetGraphicsStyleDataOfThemeDefaultGraphics(TDG_Category_Architecture_Column))
        && CreateGraphicsStyleAndGraphicsMaterialForCategoryExt(pDoc, BuiltInCategoryUniIdentities::BICU_CONSTRUCTIONAL_FLOOR, GetGraphicsStyleDataOfThemeDefaultGraphics(TDG_Category_Constructional_Floor))
        && CreateGraphicsStyleAndGraphicsMaterialForCategoryExt(pDoc, BuiltInCategoryUniIdentities::BICU_CEILING, GetGraphicsStyleDataOfThemeDefaultGraphics(TDG_Category_Ceiling))
        && CreateGraphicsStyleAndGraphicsMaterialForCategoryExt(pDoc, BuiltInCategoryUniIdentities::BICU_CURTAIN_WALL, GetGraphicsStyleDataOfThemeDefaultGraphics(TDG_Category_Curtain_Wall))
        && CreateGraphicsStyleAndGraphicsMaterialForCategoryExt(pDoc, BuiltInCategoryUniIdentities::BICU_NEW_STAIR, GetGraphicsStyleDataOfThemeDefaultGraphics(TDG_Category_New_Stair))
        && CreateGraphicsStyleAndGraphicsMaterialForCategoryExt(pDoc, BuiltInCategoryUniIdentities::BICU_NEW_HANDRAIL, GetGraphicsStyleDataOfThemeDefaultGraphics(TDG_Category_New_Handrail))
        && CreateGraphicsStyleAndGraphicsMaterialForCategoryExt(pDoc, BuiltInCategoryUniIdentities::BICU_RAMP, GetGraphicsStyleDataOfThemeDefaultGraphics(TDG_Category_Ramp))
        && CreateGraphicsStyleAndGraphicsMaterialForCategoryExt(pDoc, BuiltInCategoryUniIdentities::BICU_NEW_DOOR, GetGraphicsStyleDataOfThemeDefaultGraphics(TDG_Category_New_Door))
        && CreateGraphicsStyleAndGraphicsMaterialForCategoryExt(pDoc, BuiltInCategoryUniIdentities::BICU_NEW_WINDOW, GetGraphicsStyleDataOfThemeDefaultGraphics(TDG_Category_New_Window))
        && CreateGraphicsStyleAndGraphicsMaterialForCategoryExt(pDoc, BuiltInCategoryUniIdentities::BICU_SITE, GetGraphicsStyleDataOfThemeDefaultGraphics(TDG_Category_Site))
        && CreateGraphicsStyleAndGraphicsMaterialForCategoryExt(pDoc, BuiltInCategoryUniIdentities::BICU_COMMON_COMPONENT, GetGraphicsStyleDataOfThemeDefaultGraphics(TDG_Category_Common_Component));

    DBG_WARN_AND_RETURN_FALSE_UNLESS(res, L"内建类别创建失败",L"GDMPLab",L"2024-03-30");
    return true;
}

bool GmGraphicsStyleFilter::InitializeBuiltInCategoriesForFamily(ICategoryLibrary* pCategoryLibrary) const
{
    // 对GBMP而言，目前项目文档和族文档含有相同的内建类别
    return InitializeBuiltInCategoriesForProject(pCategoryLibrary);
}

bool GmGraphicsStyleFilter::InitializeGraphicsStyleAndGraphicsMaterialOfBuiltInCategoriesForFamily(gcmp::IDocument* pDoc)const
{
    return InitializeGraphicsStyleAndGraphicsMaterialOfBuiltInCategoriesForProject(pDoc);
}


std::vector<gcmp::UniIdentity> GmGraphicsStyleFilter::GetInternalCategoriesForObjectStyleSetting(const gcmp::IDocument* pDocument) const
{
    std::vector<UniIdentity> categories_4_internal;

    const IConfigRecord* pInHouseModeConfigRecord = IPublishConfig::GetConfigRecord(PublishConfigRecordNames::InHouseMode);
    if (pInHouseModeConfigRecord && pInHouseModeConfigRecord->IsInternalIdentifyCodeValue())
    {
        categories_4_internal.push_back(BuiltInCategoryUniIdentities::BICU_SKETCH_ROOF_BOUNDARY_CURVE);
        categories_4_internal.push_back(BuiltInCategoryUniIdentities::BICU_CURSOR_TIP);
        categories_4_internal.push_back(BuiltInCategoryUniIdentities::BICU_SKETCH);
        categories_4_internal.push_back(BuiltInCategoryUniIdentities::BICU_REFERENCED_CURVE);
        categories_4_internal.push_back(BuiltInCategoryUniIdentities::BICU_WORK_PLANE);
        //categories_4_internal.push_back(BuiltInCategoryUniIdentities::BICU_PROFILE);
        categories_4_internal.push_back(BuiltInCategoryUniIdentities::BICU_AUXILIARY_ELEMENT);
        categories_4_internal.push_back(BuiltInCategoryUniIdentities::BICU_MAGICAD_FAMILY);
        categories_4_internal.push_back(BuiltInCategoryUniIdentities::BICU_SKETCH_AXIS_LINE);
        categories_4_internal.push_back(BuiltInCategoryUniIdentities::BICU_TEMP_DIMENSION_TEXT);
        categories_4_internal.push_back(BuiltInCategoryUniIdentities::BICU_INSTANCE_JOIN);
        categories_4_internal.push_back(BuiltInCategoryUniIdentities::BICU_INSTANCE_CUT);
        categories_4_internal.push_back(BuiltInCategoryUniIdentities::BICU_ELEMENT_OPENING);
        categories_4_internal.push_back(BuiltInCategoryUniIdentities::BICU_SKETCH_PLANE);
        categories_4_internal.push_back(BuiltInCategoryUniIdentities::BICU_VIEW_SYMBOL);
        categories_4_internal.push_back(BuiltInCategoryUniIdentities::BICU_DRAWING_LINE);
        categories_4_internal.push_back(BuiltInCategoryUniIdentities::BICU_POINT_SET);
        categories_4_internal.push_back(BuiltInCategoryUniIdentities::BICU_SECTION_VIEW_SYMBOL_BORDER);
        categories_4_internal.push_back(BuiltInCategoryUniIdentities::BICU_TEMP_DIMENSION_REFERENCE_LINE);
        categories_4_internal.push_back(BuiltInCategoryUniIdentities::BICU_DISTANCE_CONSTRAINT);
        categories_4_internal.push_back(BuiltInCategoryUniIdentities::BICU_TEMP_DIMENSION_HEAD);
        categories_4_internal.push_back(BuiltInCategoryUniIdentities::BICU_SNAP_HIGHLIGHT);
        //categories_4_internal.push_back(BuiltInCategoryUniIdentities::BICU_GRID_TAG);
        categories_4_internal.push_back(BuiltInCategoryUniIdentities::BICU_FAMFORM_SUBSTRACTION);
        categories_4_internal.push_back(BuiltInCategoryUniIdentities::BICU_FAMFORM_VISIABLEINPROJECT);
        categories_4_internal.push_back(BuiltInCategoryUniIdentities::BICU_SNAP_POINT);
        categories_4_internal.push_back(BuiltInCategoryUniIdentities::BICU_TEMP_DIMENSION_LINE);
        categories_4_internal.push_back(BuiltInCategoryUniIdentities::BICU_WORK_PLANE_GRID);
        categories_4_internal.push_back(BuiltInCategoryUniIdentities::BICU_TEMP_STYLE);
        categories_4_internal.push_back(BuiltInCategoryUniIdentities::BICU_CONSTRAINT_SIGN);
        categories_4_internal.push_back(BuiltInCategoryUniIdentities::BICU_DOC_REFERENCE);
        categories_4_internal.push_back(BuiltInCategoryUniIdentities::BICU_REFERENCELINE_DATUMPLANE);
        categories_4_internal.push_back(BuiltInCategoryUniIdentities::BICU_LENGTH_MEASURE_TOOL);
        categories_4_internal.push_back(BuiltInCategoryUniIdentities::BICU_ANGLE_MEASURE_TOOL);
        categories_4_internal.push_back(BuiltInCategoryUniIdentities::BICU_PROFILE_EDIT_PLANE);
    }

    return categories_4_internal;
}

std::vector<gcmp::UniIdentity> GmGraphicsStyleFilter::InitDefaultCategory(const gcmp::IDocument* pDocument, const std::set<gcmp::UniIdentity>& srcCategories) const
{
    std::vector<UniIdentity> retCategories;
    if (IBehaviorConfig::GetConfigRecordValueAsString(BehaviorConfigRecordNames::ProductType) == ProductTypeRecordValues::FamilyEditor)
    {
        // 族编辑器用户版仅显示以下类型
        FOR_EACH(uid, srcCategories)
        {
            if (m_familyEditorCategories.find(uid) != m_familyEditorCategories.end())
            {
                retCategories.push_back(uid);
            }
        }
    }
    else if (IBehaviorConfig::GetConfigRecordValueAsString(BehaviorConfigRecordNames::ProductType) == ProductTypeRecordValues::StructuralDetailing)
    {
        // 排砖产品不显示以下类型
        FOR_EACH(uid, srcCategories)
        {
            if (m_structuralDetailingCategoriesExcluded.find(uid) == m_structuralDetailingCategoriesExcluded.end())
            {
                retCategories.push_back(uid);
            }
        }
    }
    else
    {
        FOR_EACH(uid, srcCategories)
        {
            retCategories.push_back(uid);
        }
    }

    if (pDocument->IsFamilyDocument())
    {
        // 增加当前族类型的样式
        const gfam::IFamilyManager* pFamilyManager = gfam::IFamilyManager::Get(pDocument);
        UniIdentity categoryUid = pFamilyManager->GetBasicInformation()->GetCategoryUid();
        retCategories.push_back(categoryUid);
    }

    return retCategories;
}

////////////////////////////////////////////////////////////////////////////////

std::vector<UniIdentity> GmGraphicsStyleFilter::GetCategoriesForObjectStyleSetting(const IDocument* pDoc) const
{
    std::vector<UniIdentity> allCategories;

    allCategories.push_back(BuiltInCategoryUniIdentities::BICU_STRUCTURE_WALL);
    allCategories.push_back(BuiltInCategoryUniIdentities::BICU_STRUCTURE_COLUMN);
    allCategories.push_back(BuiltInCategoryUniIdentities::BICU_STRUCTURE_BEAM);
    allCategories.push_back(BuiltInCategoryUniIdentities::BICU_STRUCTURE_FLOOR);
    allCategories.push_back(BuiltInCategoryUniIdentities::BICU_STAIR);
    allCategories.push_back(BuiltInCategoryUniIdentities::BICU_WINDOW);
    allCategories.push_back(BuiltInCategoryUniIdentities::BICU_DOOR);
    allCategories.push_back(BuiltInCategoryUniIdentities::BICU_ROOF);
    allCategories.push_back(BuiltInCategoryUniIdentities::BICU_RAILING);
    allCategories.push_back(BuiltInCategoryUniIdentities::BICU_POINT_FAMILY);
    allCategories.push_back(BuiltInCategoryUniIdentities::BICU_LINE_FAMILY);
    allCategories.push_back(BuiltInCategoryUniIdentities::BICU_ELEVATION);
    allCategories.push_back(BuiltInCategoryUniIdentities::BICU_REFERENCE_PLANE);
    allCategories.push_back(BuiltInCategoryUniIdentities::BICU_GRID);
    allCategories.push_back(BuiltInCategoryUniIdentities::BICU_MODEL_LINE);
    allCategories.push_back(BuiltInCategoryUniIdentities::BICU_VIEW_SYMBOL);
    allCategories.push_back(BuiltInCategoryUniIdentities::BICU_DIMENSION_TEXT);
    allCategories.push_back(BuiltInCategoryUniIdentities::BICU_MECHANICAL_EQUIPMENT);
    allCategories.push_back(BuiltInCategoryUniIdentities::BICU_AIR_PIPE_FITTINGS);
    allCategories.push_back(BuiltInCategoryUniIdentities::BICU_AIR_PIPE_ACCESSORY);
    allCategories.push_back(BuiltInCategoryUniIdentities::BICU_PIPE_FITTINGS);
    allCategories.push_back(BuiltInCategoryUniIdentities::BICU_PIPE_LINE_ACCESSORY);
    allCategories.push_back(BuiltInCategoryUniIdentities::BICU_SKETCH_LINE);
    allCategories.push_back(BuiltInCategoryUniIdentities::BICU_FAM_CONSTRAINT);
    allCategories.push_back(BuiltInCategoryUniIdentities::BICU_SKETCH_LOCATION_LINE);
    allCategories.push_back(BuiltInCategoryUniIdentities::BICU_REFERENCE_LINE);
    allCategories.push_back(BuiltInCategoryUniIdentities::BICU_MEPCONNECTOR);
    allCategories.push_back(BuiltInCategoryUniIdentities::BICU_NEW_ROOF);
    allCategories.push_back(BuiltInCategoryUniIdentities::BICU_LINK_DOCUMENT_ELEMENT);
    allCategories.push_back(BuiltInCategoryUniIdentities::BICU_TEST_MODEL_BODY);
    return allCategories;
}

std::wstring GmGraphicsStyleFilter::GetObjectStyleSettingGroupForCategory(const UniIdentity& cateogryUid, bool isFamilyDoc) const
{
    if (isFamilyDoc)
    {
        if (m_geolabCategories.find(cateogryUid) != m_geolabCategories.end())
        {
            return L"GDMPLab对象";
        }
    }
    else
    {
        if (m_projectCategories.find(cateogryUid) != m_projectCategories.end())
        {
            return L"项目对象";
        }
    }

    return L"";
}

std::vector<std::wstring> GmGraphicsStyleFilter::GetAllObjectStyleSettingGroups(bool isFamilyDoc) const
{
    std::vector<std::wstring> allGroups;

    if (isFamilyDoc)
    {
        allGroups.push_back(L"GDMPLab对象");
    }
    else
    {
        allGroups.push_back(L"项目对象");
    }

    return allGroups;
}

gcmp::UniIdentity GmGraphicsStyleFilter::GetVisibiltyFilterGroupRelatedCategory(const std::wstring& strGroupName) const
{
    return UniIdentity();
}

////////////////////////////////////////////////////////////////////////////////

std::vector<UniIdentity> GmGraphicsStyleFilter::GetCategoriesForVisibilityFilter(const IDocument* pDoc) const
{
    // GBMP暂无此功能
    return std::vector<UniIdentity>();
}

std::wstring GmGraphicsStyleFilter::GetVisibilityFilterGroupForCategory(const UniIdentity& cateogryUid) const
{
    // GBMP暂无此功能
    return std::wstring();
}

std::vector<std::wstring> GmGraphicsStyleFilter::GetAllVisibilityFilterGroups() const
{
    // GBMP暂无此功能
    return std::vector<std::wstring>();
}

////////////////////////////////////////////////////////////////////////////////

std::vector<std::pair<UniIdentity, bool>> GmGraphicsStyleFilter::GetCategoriesForSelectionFilter(const IDocument* pDoc, bool isFamilyDoc) const
{
    std::vector<std::pair<UniIdentity, bool>> categories;

    if (isFamilyDoc)
    {
        FOR_EACH(id, m_geolabCategories)
        {
            categories.push_back(std::make_pair(id, true));
        }
    }
    else
    {
        FOR_EACH(id, m_projectCategories)
        {
            categories.push_back(std::make_pair(id, true));
        }
    }
    return categories;
}

bool GmGraphicsStyleFilter::IsCuttableCategoryByPlanViewCutPlane(const gcmp::UniIdentity& categoryUid) const
{
    static std::set<gcmp::UniIdentity> cuttableCategories =
    {
        BuiltInCategoryUniIdentities::BICU_STRUCTURE_WALL,
        BuiltInCategoryUniIdentities::BICU_STRUCTURE_BEAM,
        BuiltInCategoryUniIdentities::BICU_STRUCTURE_FLOOR,
        BuiltInCategoryUniIdentities::BICU_STRUCTURE_COLUMN,
        BuiltInCategoryUniIdentities::BICU_NEW_ROOF,

        BuiltInCategoryUniIdentities::BICU_POINT_FAMILY,
        BuiltInCategoryUniIdentities::BICU_LINE_FAMILY,
        BuiltInCategoryUniIdentities::BICU_WALL,
        BuiltInCategoryUniIdentities::BICU_WINDOW,
        BuiltInCategoryUniIdentities::BICU_DOOR,
        BuiltInCategoryUniIdentities::BICU_STAIR,
        BuiltInCategoryUniIdentities::BICU_COLUMN,
        BuiltInCategoryUniIdentities::BICU_BEAM,
        BuiltInCategoryUniIdentities::BICU_ROOF,
        BuiltInCategoryUniIdentities::BICU_FLOOR,
        BuiltInCategoryUniIdentities::BICU_RAILING,
        BuiltInCategoryUniIdentities::BICU_HANDRAIL,
        BuiltInCategoryUniIdentities::BICU_BALUSTER
    };

    return cuttableCategories.find(categoryUid) != cuttableCategories.end();
}

bool GmGraphicsStyleFilter::IsCuttableElementByPlanViewCutPlane(const gcmp::IElement* pElement) const
{
    if (DEBUG_MODE(TestCuttableElementByPlanView))
    {
        return !IsA<ILinkElementProxy>(pElement);
    }
    return true;
}


